package com.learn.springcloud.hystrixexplainindetailconsumer.request.collapser.command;

import com.learn.springcloud.hystrixexplainindetailconsumer.bean.User;
import com.learn.springcloud.hystrixexplainindetailconsumer.request.collapser.service.RequestCollapserExtendService;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

import java.util.List;

/**
 * @Time : 2018/8/6 19:57
 * @Version : 1.0
 */
public class UserBatchCommand extends HystrixCommand<List<User>> {

    private RequestCollapserExtendService requestCollapserService;
    private List<Long> userIds;

    public UserBatchCommand(RequestCollapserExtendService requestCollapserService, List<Long> userIds) {
        super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("aaa")));
        this.requestCollapserService = requestCollapserService;
        this.userIds = userIds;
    }

    @Override
    protected List<User> run() throws Exception {
        return requestCollapserService.finds(userIds);
    }
}
